from django.contrib.auth.models import User
from django.db import models


class Comment(models.Model):
    content = models.TextField(verbose_name='评论内容')
    author = models.ForeignKey(User, on_delete=models.DO_NOTHING, verbose_name='评论者')
    post_time = models.DateTimeField(auto_now_add=True, verbose_name='评论时间')
    parent = models.ForeignKey('self', null=True, blank=True, related_name='replies', on_delete=models.CASCADE,
                               verbose_name="父级评论")  # 父节点

    class Meta:
        db_table = 'comment'
        verbose_name = '评论'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.content
